package com.sjn.util.encrytion;

/**
 * 反向加密算法,将得到的data逆向输出
 */

public class ReverseEncryption extends AddEncryption{

    public ReverseEncryption(DataEncryption dataEncryption) {
        super(dataEncryption);
    }

    @Override
    public String encryption() {
        byte[] by = getDataEncryption().getData().getBytes();
        byte st = 0;
        //倒序
        for(int i=0;i<by.length;i++){
            st = by[0];
            by[0] = by[by.length-1];
            by[by.length-1] = st;
        }
        //组合
//        String nowse = new String(by);
        //交付给data
        getDataEncryption().setData(new String(by));
        //调用的是隐藏在这个类中的成员变量,所以要get传过来的dataEcry成员在调用他的方法才有数据
        //return getDataEncryption().getData();
//        return nowse;
        return getDataEncryption().getData();
    }
}
